const dbutil = require('../../../libs/MyDB');

module.exports = {
    //显示所有权限管理
    show_rules: async function(aname) {
        let roleArr = [];
        await dbutil.multiSelect('view_rules', ['rule_name','rule_url','parent_id'], `parent_id="0" and aname="${aname}"`)
            .then(
                result => {
                    roleArr = result;
                }
            )
        return roleArr;
    },


    //显示所有的角色
    show_allRole: async function() {
        let result = [];
        await dbutil.multiSelect('study_authority', 'authority_name', 'authority_id is not null')
            .then(
                res => {
                    result = res;
                }
            )
        return result;
    },

    //添加角色
    add_role: async function(roleName) {
        await dbutil.add('study_authority', {
            authority_name: roleName
        })
    }

}